package view;

import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import controller.Controller;

/*
 * 
 * MainFrame class
 * 
 * Main frame containing the JPanels where the game is displayed.
 * 
 */

public class MainFrame extends JFrame {

	private static final long serialVersionUID = 8893460252427647061L;
	ImageIcon screen;

	/**
	 * MainFrame
	 * 
	 * creates the MainFrame of the game using the controller passed into it
	 * 
	 * @param c
	 */
	public MainFrame(Controller c) {
		setSize(800, 600);
		setResizable(false);
		setVisible(true);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.addKeyListener(new UserInputListener(c));
		importSprites();
		JLabel block = new JLabel();
		block.setIcon(screen);
		this.add(block);
		this.setVisible(true);
	}

	/**
	 * importSprite
	 * 
	 * imports a sprite based upon a the passed in path
	 * 
	 * @param path
	 * @return
	 */
	private ImageIcon importSprite(String path) {
		URL sprite = getClass().getResource(path);
		if (sprite == null) {
			return null;
		} else
			return new ImageIcon(sprite);
	}

	/**
	 * importSprites
	 * 
	 * imports the sprite for the main screen
	 */
	private void importSprites() {
		screen = importSprite("/textures/lemonAdventure.png");
	}
}
